package com.narunas.view
{
	import com.narunas.ApplicationFacade;
	import com.narunas.view.component.Navigation;
	import com.narunas.view.layout.resize.*;
	
	import flash.display.Sprite;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	

	public class NavigationMediator extends Mediator implements IMediator
	{
		public static const NAME:String = "navigation_mediator";
		
		//navigation components:
		private var nav_base:Sprite;
		
		public function NavigationMediator(viewComponent:Object=null)
		{
			super(NAME, viewComponent);
			
		}
		override public function listNotificationInterests():Array
		{
			return [
					ApplicationFacade.INIT_NAVIGATION
					];
		}
		
		override public function handleNotification(n:INotification):void
		{
			super.handleNotification(n);
			switch(n.getName()) {
				case ApplicationFacade.INIT_NAVIGATION:
					
					nav_base = new Navigation(base.stage);
					base.addChild(nav_base);
					
					sendNotification(ApplicationFacade.ADD_TO_RESIZER, nav_base); 
				
				break;
			}
		}
		

		override public function getMediatorName():String
		{
			return NAME;
		}
		
		override public function getViewComponent():Object
		{
			return viewComponent;
		}
		
		override public function setViewComponent(viewComponent:Object):void
		{
		}
		
		override public function onRegister():void
		{
		}
		
		override public function onRemove():void
		{
		}
		
		private function get base():Sprite {
			return MainApp(app);
		}
		
		private function get app():MainApp {
			return viewComponent as MainApp;
		}
	}
}